import qrcode

from io import BytesIO
from uuid import uuid4


def build_qrcode():
	uuid = str(uuid4())
	byte_image = BytesIO()
	qr = qrcode.QRCode(version=5, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=5, border=5)
	qr.add_data(f'http://www.cnblogs.com/sfnz/?s={uuid}')
	qr.make(fit=True)
	img = qr.make_image()
	img.width = 200
	img.height = 200
	# img.show()
	img.save(byte_image, 'png')
	return byte_image.getvalue(), uuid


if __name__ == "__main__":
	print(build_qrcode())
